/*
 * Powered By [信安]
 * Since 2013 - 2013
 */

package com.xinan.system.curd;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

import java.sql.Timestamp;
import java.util.List;

/**
 * @author EricLee
 * @version 1.0
 * @since 1.0
 */

@TableBind(tableName = "auth_role")
public class AuthRole extends Model<AuthRole>{
    public static final AuthRole dao = new AuthRole();

	//columns START
	public int getId() {
		return get("id");
	}
	public String getName() {
		return get("name");
	}
	public String getRmk() {
		return get("rmk");
	}
	public String getOptname() {
		return get("optname");
	}
	public Timestamp getOptdate() {
		return get("optdate");
	}
	//columns END
    public List<AuthRole> findAll() {
        return find("select * from auth_role");
    }

    public Page<AuthRole> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from auth_role";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        return paginate(pageNumber, pageSize, "select *", sqlExp);
    }
    public AuthRole findByRoleName(String roleName)
    {
        return findFirst("select * from auth_role where name = ?",roleName);
    }

}

